// Package sys
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.16.10
package sys

import (
	"context"
	"hotgo/api/admin/systenantpackage"
	"hotgo/internal/model/input/sysin"
	"hotgo/internal/service"
)

var (
	SysTenantPackage = cSysTenantPackage{}
)

type cSysTenantPackage struct{}

// List 查看租户套餐列表
func (c *cSysTenantPackage) List(ctx context.Context, req *systenantpackage.ListReq) (res *systenantpackage.ListRes, err error) {
	list, totalCount, err := service.SysTenantPackage().List(ctx, &req.SysTenantPackageListInp)
	if err != nil {
		return
	}

	if list == nil {
		list = []*sysin.SysTenantPackageListModel{}
	}

	res = new(systenantpackage.ListRes)
	res.List = list
	res.PageRes.Pack(req, totalCount)
	return
}

// Export 导出租户套餐列表
func (c *cSysTenantPackage) Export(ctx context.Context, req *systenantpackage.ExportReq) (res *systenantpackage.ExportRes, err error) {
	err = service.SysTenantPackage().Export(ctx, &req.SysTenantPackageListInp)
	return
}

// Edit 更新租户套餐
func (c *cSysTenantPackage) Edit(ctx context.Context, req *systenantpackage.EditReq) (res *systenantpackage.EditRes, err error) {
	err = service.SysTenantPackage().Edit(ctx, &req.SysTenantPackageEditInp)
	return
}

// View 获取指定租户套餐信息
func (c *cSysTenantPackage) View(ctx context.Context, req *systenantpackage.ViewReq) (res *systenantpackage.ViewRes, err error) {
	data, err := service.SysTenantPackage().View(ctx, &req.SysTenantPackageViewInp)
	if err != nil {
		return
	}

	res = new(systenantpackage.ViewRes)
	res.SysTenantPackageViewModel = data
	return
}

// Delete 删除租户套餐
func (c *cSysTenantPackage) Delete(ctx context.Context, req *systenantpackage.DeleteReq) (res *systenantpackage.DeleteRes, err error) {
	err = service.SysTenantPackage().Delete(ctx, &req.SysTenantPackageDeleteInp)
	return
}

// Status 更新租户套餐状态
func (c *cSysTenantPackage) Status(ctx context.Context, req *systenantpackage.StatusReq) (res *systenantpackage.StatusRes, err error) {
	err = service.SysTenantPackage().Status(ctx, &req.SysTenantPackageStatusInp)
	return
}
